﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Icinetic.FeedCategorySample.Entities;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Icinetic.FeedCategorySample.Common
{
    public class VariableGridView : GridView
    {
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var viewModel = item as RssItem;

            if (viewModel != null)
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, viewModel.ColSpan);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, viewModel.RowSpan);
            }

            base.PrepareContainerForItemOverride(element, item);
        }
    }

    public class VariableGridViewPortrait : GridView
    {
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            var viewModel = item as RssItem;

            if (viewModel != null)
            {
                element.SetValue(VariableSizedWrapGrid.ColumnSpanProperty, viewModel.ColPortraitSpan);
                element.SetValue(VariableSizedWrapGrid.RowSpanProperty, viewModel.RowPortraitSpan);
            }

            base.PrepareContainerForItemOverride(element, item);
        }
    }
}
